package NC67_汉诺塔问题;

import java.util.*;

public class Solution {
    ArrayList<String> list = new ArrayList<>();
    public ArrayList<String> getSolution(int n) {
        // write code here
        Hanoi(n, "left", "mid", "right");
        return list;
    }

    private void Hanoi(int n, String left, String mid, String right) {
        if (n == 0){
            return;
        }
        Hanoi(n - 1, left, right, mid); // 把 n - 1 个盘子从 left 借助 right 搬到 mid 去
        list.add("move from " + left + " to " + right);    // 把第 n 个盘子从 left 搬到 right 上
        Hanoi(n - 1, mid, left, right); //把 n - 1 个盘子从 mid 借助 left 搬到 right 去
    }
}